package gateway

import (
	"fmt"
	"github.com/gorilla/websocket"
	"net/http"
	"runtime/debug"
)

type HandlerFunc func(ctx *Context)

var signal Signal

var events Events

var ctxType string


type Way interface {
	Handle(options Options)
	GatewayManager(w http.ResponseWriter, r *http.Request)
	Alloter(ws *websocket.Conn)
}

type Options struct {
	Host string
	Port int
	CtxType string
}

func Handle(way Way,options Options){
	way.Handle(options)
}


func endStack(appName string) {
	if err := recover(); err != nil {
		//将客户端的这次请求头、主体等信息+程序的堆栈信息
		msg := map[string]interface{}{
			"error": err,                   //真正的错误信息
			"wspl":  appName,               //连接句柄信息
			"stack": string(debug.Stack()), //此刻程序的堆栈信息
		}
		fmt.Println(msg)
	}
}
